<template>
	<view class="detail_box">
		<u-navbar :auto-back="true" :placeholder="true" title=" "></u-navbar>
		<view v-if="detail">
			<view class="detail_title">{{detail.title}}</view>
			<view class="flex_box detail_b">
				<view v-if="from == 'news'" class="detail_see"><text>{{detail.views}}</text>浏览</view>
				<view class="detail_time">{{detail.createtime | date}}</view>
			</view>
			<view class="detail_content">
				<u-parse :content="detail.content"></u-parse>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		infoDetail,
		noticeDetail
	} from '@/common/http.api.js';
	let that;
	export default {
		data() {
			return {
				id: "",
				from: 'news',
				detail: null
			}
		},
		onLoad(options) {
			that = this
			if(options.id) that.id = options.id
			if(options.from) that.from = options.from
			that.getDetail()
		},
		methods: {
			// 获取详情
			getDetail(){
				let that = this
				if(that.from == 'notice'){
					noticeDetail({id: that.id}).then(res => {
						that.detail = res.data;
					}).catch(err => {
						uni.$u.toast(err.msg);
					});
				}else{
					infoDetail({id: that.id}).then(res => {
						that.detail = res.data;
					}).catch(err => {
						uni.$u.toast(err.msg);
					});
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.detail_box{
		padding: 30rpx;
		.detail_title{
			font-size: 40rpx;
			color: #1E272E;
			font-weight: bold;
			line-height: 58rpx;
			margin-bottom: 20rpx;
		}
		.detail_b{
			height: 60rpx;
			font-size: 28rpx;
			color: #999999;
			.detail_see{
				color: #808E9B;
				margin-right: 50rpx;
				text{
					color: #1E272E;
					font-weight: 500;
					margin-right: 8rpx;
				}
			}
			.detail_time{
				color: #999999;
			}
		}
		.detail_content{
			padding: 30rpx 0 0;
			font-size: 28rpx;
			line-height: 40rpx;
			color: #333333;
		}
	}
</style>
